package com.nanxhs.health.starter.config;

import com.nanxhs.health.starter.properties.HealthProperties;
import com.nanxhs.health.starter.service.MonitorCore;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 *
 * starter自动配置条件
 *
 * @author 唐海斌
 * @date 2021/8/13 15:02
 */
@Configuration
@EnableConfigurationProperties({HealthProperties.class})
@ConditionalOnProperty(
        prefix = "health",
        name = "open",
        havingValue = "true"
)
public class HealthConfig {

    @Bean
    public MonitorCore monitorCore(@Autowired HealthProperties healthProperties) {
        return new MonitorCore(healthProperties);
    }
}
